#include "MapperColorDreams.h"
#include "Log.h"
PNE_NAMESPACE_BEGIN

MapperColorDreams::MapperColorDreams(Cartridge &cart,
                                     std::function<void(void)> mirroring_callback)
    : Mapper(cart, Mapper::Type::ColorDreams),
      m_mirroring(NameTableMirroring::Vertical),
      m_mirroringCallback(mirroring_callback)

{
}

Byte MapperColorDreams::ReadPRG(Address addr)
{
    if (addr >= 0x8000)
    {
        return m_cartridge.GetROM()[(prgbank * 0x8000) + (addr & 0x7fff)];
    }

    return 0;
}

void MapperColorDreams::WritePRG(Address addr, Byte value)
{
    if (addr >= 0x8000)
    {
        prgbank = ((value >> 0) & 0x3);
        chrbank = ((value >> 4) & 0xf);
    }
}

Byte MapperColorDreams::ReadCHR(Address addr)
{
    if (addr <= 0x1FFF)
    {
        return m_cartridge.GetVROM()[(chrbank * 0x2000) + addr];
    }

    return 0;
}

NameTableMirroring MapperColorDreams::GetNameTableMirroring()
{
    return m_mirroring;
}

void MapperColorDreams::WriteCHR(Address addr, Byte value)
{
}
PNE_NAMESPACE_END
// DONE